<template>
  <div>
    <el-dialog class="dialog" title="商品详情" :visible.sync="dialogFormVisible" :before-close="close">
      <el-form :model="form">
        <el-row>
          <el-col :span="10">
            <el-form-item label="商品名：" :label-width="formLabelWidth">
              <!-- <el-input v-model="form.account" auto-complete="off" @blur="accountBlur" /> -->
              <el-input v-model="form.name" auto-complete="off" placeholder="商品名" disabled />
            </el-form-item>
          </el-col>
          <el-col :span="10">
            <el-form-item label="单价：" :label-width="formLabelWidth">
              <el-input v-model="form.price" auto-complete="off" placeholder="商品单价" disabled />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="10">
            <el-form-item label="商品编号：" :label-width="formLabelWidth">
              <!-- <el-input v-model="form.account" auto-complete="off" @blur="accountBlur" /> -->
              <el-input v-model="form.number" auto-complete="off" placeholder="商品编号" disabled />
            </el-form-item>
          </el-col>
          <el-col :span="10">
            <el-form-item label="商品类别：" :label-width="formLabelWidth">
              <el-select v-model="form.type" placeholder="商品类别" style="width:100%" disabled>
                <el-option label="区域一" value="shanghai" />
                <el-option label="区域二" value="beijing" />
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="10">
            <el-form-item label="库存：" :label-width="formLabelWidth">
              <el-input v-model="form.repertory" auto-complete="off" placeholder="商品库存" disabled />
            </el-form-item>
          </el-col>
          <el-col :span="10">
            <el-form-item label="销量：" :label-width="formLabelWidth">
              <el-input v-model="form.amount" auto-complete="off" placeholder="商品销量" disabled />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="10">
            <el-form-item label="进价：" :label-width="formLabelWidth">
              <el-input v-model="form.originalPrice" auto-complete="off" placeholder="商品进价" disabled />
            </el-form-item>
          </el-col>
          <el-col :span="10">
            <el-form-item label="进货日期：" :label-width="formLabelWidth">
              <el-date-picker v-model="form.stockTime" type="date" placeholder="选择日期" style="width: 100%;" disabled />
              <!-- <el-input v-model="form.stockTime" auto-complete="off" /> -->
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="10">
            <el-form-item label="商品状态：" :label-width="formLabelWidth">
              <el-switch v-model="form.status" disabled />
            </el-form-item>
          </el-col>
          <el-col :span="10" />
        </el-row>
        <el-row>
          <el-col :span="20">
            <el-form-item label="介绍：" :label-width="formLabelWidth">
              <el-input v-model="form.description" type="textarea" placeholder="商品简单介绍" disabled />
            </el-form-item>
          </el-col>
        </el-row>
        <el-form-item class="headPortrait" label="商品图：" :label-width="formLabelWidth">
          <!-- <el-upload
            action="https://www.easy-mock.com/mock/5d6299a11fc89667465ec0e7/user/avatar"
            list-type="picture-card"
            :on-preview="handlePictureCardPreview"
            :on-remove="handleRemove"
          >
            <i class="el-icon-plus" />
          </el-upload> -->
          <!-- <el-dialog :visible.sync="dialogVisible" size="tiny">
            <img width="100%" :src="imageUrl" alt="">
          </el-dialog> -->
        </el-form-item>
      </el-form>
    </el-dialog>
  </div>
</template>

<script>
export default {
  name: 'LookGood',
  props: {
    lookGood: {
      type: Boolean,
      default: false
    },
    row: {
      type: Object,
      default: () => {}
    }
  },
  data() {
    return {
      dialogFormVisible: false,
      form: {
        name: '',
        number: '',
        type: [],
        price: '',
        amount: '',
        repertory: '',
        originalPrice: '',
        stockTime: '',
        description: '',
        status: false
      },
      imageUrl: '',
      formLabelWidth: '90px',
      formRegionWidth: '100%'
    }
  },
  watch: {
    lookGood(newVal) {
      if (newVal) {
        this.dialogFormVisible = newVal
        this.form = this.row
        console.log(this.row)
      }
    }
  },
  methods: {
    close() {
      const data = 'look'
      this.dialogFormVisible = false
      this.$emit('closeEdit', data)
    }
  }
}
</script>

<style lang="stylus" scoped>
.dialog >>> .el-dialog
  width 60%
  .avatar-uploader >>> .el-upload
    border 1px dashed #d9d9d9
    border-radius 6px
    cursor pointer
    position relative
    overflow hidden
  .avatar-uploader >>> .el-upload:hover
    border-color #409EFF
  .addAccount >>> .regionSelect
    width 100%
.addAccount
  padding-left 20px
  padding-top 20px
  .avatar-uploader-icon
    font-size 28px
    color #8c939d
    text-align center
  .avatar
    width 178px
    height 178px
    display block
</style>
